home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-07-07 | 9.3 KB | 386 lines | [TEXT/MPS ] |
- // Copyright, ©1994 Apple Computer. All rights reserved.
-
- // app constants
-
- constant kAppSymbol := '|NewTextFuncs:PIEDTS|;
- constant kAppname := "New Text Funcs" ;
-
- constant kAppMaxWidth := 240 ;
- constant kAppMaxHeight := 336 ;
-
-
- // error strings
- DefConst('kAppErrors,
- ["There is no Source Text to display",
- ]);
-
- constant kNoTextError := 0 ;
- // ---- End Project Data ----
-
-
- // ---- File NewTextFuncs.t ----
- myBase :=
- {viewBounds: {left: 0, top: 2, right: 236, bottom: 310},
- viewFormat: 83951953,
- viewSetupFormScript:
- func()
- begin
- a := GetAppParams();
- viewBounds := RelBounds(a.AppAreaLeft, a.AppAreaTop,
- MIN(a.AppAreaWidth, kAppMaxWidth),
- MIN(a.AppAreaHeight, kAppMaxHeight));
- end,
- DoError:
- func(errorID, params)
- begin
- local errorString := Clone(kAppErrors[errorID]) ;
- if params then
- errorString := ParamStr(errorString, params) ;
- :Notify(kNotifyAlert, EnsureInternal(kAppName), errorString);
- end,
- declareSelf: 'base,
- DrawFunkyText:
- func(myText, funkyFontFrame)
- begin
- local b := :LocalBox();
- local bounds := SetBounds(0, 0, 0, 0) ; // temporary use only
-
- // get the bounding box required for the text
- TextBounds(myText, funkyFontFrame, bounds);
-
- // just to make things look nice, clear our view
- :DrawShape(MakeRect(b.left, b.top, b.right, b.bottom), {fillpattern:vfWhite});
-
- // now have some fun blasting the text around
- local height := bounds.bottom - bounds.top;
- local width := bounds.right - bounds.left;
-
- // make the text fit completely horizontally within us
- local horizontalMax := (b.right - b.left) - width;
-
- // make the text fit completely vertically within us
- local verticalMax := (b.bottom - b.top) - height;
-
- for i := 1 to 100 do
- TextBox(myText, funkyFontFrame,
- RelBounds(Random(0, horizontalMax), Random(0, verticalMax), width, height));
-
- :Dirty(); // redraw our entire application
- RefreshViews(); // refresh immediately so the textbutton 'unhilite' will look pretty
- end,
- _proto: protoApp,
- debug: "myBase"
- };
-
- theText := /* child of myBase */
- {viewFlags: 33553921,
- viewFormat: 209233,
- viewlinespacing: 20,
- viewBounds: {left: 6, top: 25, right: 234, bottom: 95},
- text: "Some text with\nline breaks in places\nthat are breaks",
- viewFont: nil,
- viewSetupFormScript:
- func()
- begin
- viewFont := userconfiguration.userFont ;
- end,
- viewclass: 81,
- debug: "theText"
- };
- // View theText is declared to myBase
-
-
-
- _view000 := /* child of myBase */
- {text: "Display Text",
- buttonClickScript:
- func()
- begin
- local bounds := SetBounds(0, 0, 0, 0) ;
- local funkyFontFrame := {font: FontStyle:GetFontFrame(),
- justification: Justification:GetJustification()};
-
- if StrLen(theText.text) < 1 then
- return :DoError(kNoTextError, nil) ;
-
-
- local myText := theText.text ;
-
- // do not need to display the new viewbounds
- newViewBounds:Close();
- targetText:Close();
-
- if functionType.clusterValue = 'TextBox then
- begin
- base:DoDrawing('DrawFunkyText, [myText, funkyFontFrame]);
- end;
- else begin // if we are using the function called TextBounds
- local newBounds := Clone(bounds);
-
- TextBounds(myText, funkyFontFrame, newBounds);
-
- newViewBounds:SetText(bounds, newBounds);
-
- targetText.text := myText ;
- targetText.funkyFont := funkyFontFrame ;
- targetText.textBounds := newBounds ;
-
- targetText:Open();
- newViewbounds:Open();
- end;
- end,
- viewBounds: {left: 10, top: 194, right: 130, bottom: 210},
- _proto: protoTextButton
- };
-
-
-
- targetText := /* child of myBase */
- {viewBounds: {left: 9, top: 117, right: 231, bottom: 187},
- viewFormat: 336,
- viewEffect: 8625185,
- viewFlags: 0,
- text: "",
- viewDrawScript:
- func()
- begin
- TextBox(text, funkyFont, textBounds);
- end,
- funkyFont: nil,
- TextBounds: nil,
- viewclass: 74,
- debug: "targetText"
- };
- // View targetText is declared to myBase
-
-
-
- functionType := /* child of myBase */
- {viewBounds: {left: 141, top: 261, right: 227, bottom: 299},
- clusterValue: 'TextBox,
- viewFormat: 336,
- _proto: protoRadioCluster,
- debug: "functionType"
- };
- // View functionType is declared to myBase
-
- _view001 := /* child of functionType */
- {buttonValue: 'TextBox,
- viewBounds: {left: 9, top: 5, right: 75, bottom: 21},
- text: "TextBox",
- _proto: protoRadioButton
- };
-
-
-
- _view002 := /* child of functionType */
- {buttonValue: 'TextBounds,
- viewBounds: {left: 9, top: 21, right: 75, bottom: 37},
- text: "TextBounds",
- _proto: protoRadioButton
- };
-
-
-
-
-
- _view003 := /* child of myBase */
- {text: "Use Function:",
- viewBounds: {left: 145, top: 254, right: 207, bottom: 270},
- viewFormat: 1,
- viewFont: simpleFont9,
- _proto: protoStaticText
- };
-
-
-
- _view004 := /* child of myBase */
- {text: "Source Text",
- viewBounds: {left: 8, top: 8, right: 72, bottom: 24},
- _proto: protoStaticText
- };
-
-
-
- _view005 := /* child of myBase */
- {text: "Target View",
- viewBounds: {left: 8, top: 100, right: 72, bottom: 116},
- _proto: protoStaticText
- };
-
-
-
- FontStyle := /* child of myBase */
- {viewFlags: 1,
- viewFormat: 336,
- viewBounds: {left: 9, top: 241, right: 119, bottom: 303},
- GetFontFrame:
- func()
- begin
- {family: FontFamily:GetFamily(),
- face: FontFace:GetFace(),
- size: FontSize:GetSize()}
- end,
- viewclass: 74,
- debug: "FontStyle"
- };
- // View FontStyle is declared to myBase
-
- FontFamily := /* child of FontStyle */
- {viewBounds: {left: 5, top: 7, right: 107, bottom: 21},
- viewSetupFormScript:
- func()
- begin
- self.labelCommands :=
- foreach slot, val deeply in fonts collect
- Capitalize(SprintObject(slot));
- inherited:?viewSetupFormScript()
- end,
- text: "Family",
- GetFamily:
- func()
- begin
- Intern(entryLine.text);
- end,
- _proto: protoLabelPicker,
- debug: "FontFamily"
- };
- // View FontFamily is declared to FontStyle
-
-
-
- FontFace := /* child of FontStyle */
- {viewBounds: {left: 5, top: 27, right: 107, bottom: 41},
- text: "Face",
- labelCommands: ["Normal", "Bold", "Italic", "Underline"],
- labelActionScript:
- func(cmd)
- begin
- currIndex := cmd;
- end,
- currIndex: 0,
- GetFace:
- func()
- begin
- if currIndex = 0 then
- kFaceNormal;
- else if currIndex = 1 then
- kFaceBold;
- else if currIndex = 2 then
- kFaceItalic;
- else
- kFaceUnderline;
- end,
- _proto: protoLabelPicker,
- debug: "FontFace"
- };
- // View FontFace is declared to FontStyle
-
-
-
- FontSize := /* child of FontStyle */
- {viewBounds: {left: 5, top: 47, right: 107, bottom: 61},
- text: "Size",
- labelCommands: ["9", "10", "12", "14", "18"],
- currIndex: 0,
- labelActionScript:
- func(cmd)
- begin
- currIndex := cmd;
- end,
- GetSize:
- func()
- begin
- if currIndex = 0 then
- 9;
- else if currIndex = 1 then
- 10;
- else if currIndex = 2 then
- 12;
- else if currIndex = 3 then
- 14;
- else
- 18;
- end,
- _proto: protoLabelPicker,
- debug: "FontSize"
- };
- // View FontSize is declared to FontStyle
-
-
-
-
-
- _view006 := /* child of myBase */
- {text: "Use Font:",
- viewBounds: {left: 12, top: 234, right: 56, bottom: 250},
- viewFont: simpleFont9,
- viewFormat: 1,
- _proto: protoStaticText
- };
-
-
-
- Justification := /* child of myBase */
- {viewBounds: {left: 9, top: 217, right: 131, bottom: 235},
- labelCommands: ["Left", "Center", "Right"],
- GetJustification:
- func()
- begin
- Intern(entryLine.text);
- end,
- text: "Justification",
- _proto: protoLabelPicker,
- debug: "Justification"
- };
- // View Justification is declared to myBase
-
-
-
- newViewbounds := /* child of myBase */
- {viewFlags: 0,
- viewFormat: 336,
- viewBounds: {left: 137, top: 193, right: 231, bottom: 251},
- viewFont: {family: 'espy, face: kFaceNormal, size: 9},
- viewDrawScript:
- func()
- begin
- TextBox(displayText, {font: viewFont, justification: 'center},
- :LocalBox());
- end,
- viewEffect: 8625185,
- sourceText: "Source Viewbounds:\n^0\nNew Viewbounds:\n^1",
- displaytext: nil,
- SetText:
- func(sourceBounds, newBounds)
- begin
- local s := "(", n := "(" ;
- foreach x in sourceBounds do
- s := s & NumberStr(x) & ", ";
- StrMunger(s, StrLen(s) - 2, 2, ")", 0, 1);
-
- foreach x in newBounds do
- n := n & NumberStr(x) & ", ";
- StrMunger(n, StrLen(n) - 2, 2, ")", 0, 1);
-
- displayText := ParamStr(sourceText, [s, n]);
- end,
- viewclass: 74,
- debug: "newViewbounds"
- };
- // View newViewbounds is declared to myBase
-
-
-
- // After Script for "myBase"
- thisView := myBase;
- // Copyright, ©1994 Apple Computer. All rights reserved.
- thisView.title := kAppName;
-
-
-
-
-
- // ---- Beginning of section for non used Layout files ----
-
- // End of output